package com.github.io.utils;

import lombok.Data;

/**
 * @author: ruiyanglee
 * @date: 2020-09-08 13:48
 * @description: 统一返回结果对象
 */
@Data
public class ResponseResult {
    private Boolean success;
    private Integer code;
    private String message;
    private Object data;

    private ResponseResult() {
    }


    public static ResponseResult ok() {
        ResponseResult response = new ResponseResult();
        response.code = ResultCode.SUCCESS;
        response.success = true;
        return response;
    }

    public static ResponseResult error() {
        ResponseResult response = new ResponseResult();
        response.success = false;
        return response;
    }

    public ResponseResult message(String message) {
        this.message = message;
        return this;
    }

    public ResponseResult data(Object data) {
        this.data = data;
        return this;
    }

    public ResponseResult code(Integer code) {
        this.code = code;
        return this;
    }
}
